package com.itheima.store.service.impl;

import com.itheima.store.dao.CategoryDao;
import com.itheima.store.entity.Category;
import com.itheima.store.service.CategoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CategoryServiceImpl implements CategoryService {

    @Autowired
    private CategoryDao categoryDao;

    @Override
    public List<Category> findAll() {

        return categoryDao.findAll();
    }

    @Override
    public Category findCategoryById(String cid) {
        return categoryDao.findCategoryById(cid);
    }

    @Override
    public boolean deleteCategory(String cid) {
        return categoryDao.deleteCategory(cid)>0?true:false;
    }

    @Override
    public boolean editCategoryById(String cid, String cname) {
        return categoryDao.editCategoryById(cid,cname)>0?true:false;
    }

    @Override
    public boolean addCategory(String cname ,String ccid) {
        return categoryDao.addCategory(cname,ccid)>0?true:false;
    }
}
